<%@page import="java.util.List"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.model.Problem"%>
<%@page import="com.shsh.safemanage.dao.ProblemDao"%>
<%@page import="com.shsh.safemanage.model.Role"%>
<%@page import="com.shsh.safemanage.action.UserAction"%>
<%@page import="com.shsh.safemanage.model.Department1"%>
<%@page import="com.shsh.safemanage.action.ActionCreator"%>
<%@page import="com.shsh.safemanage.action.WriteProblemAction"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.TitlePostManageGroupDao"%>
<%@page import="com.shsh.safemanage.dao.RoleDao"%>
<%@page import="com.shsh.safemanage.model.JobPost"%>
<%@page import="com.shsh.safemanage.model.User"%>
<%@page import="com.shsh.safemanage.util.Constants"%>

<%
{
String theProblemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
Long theProblemID = 0L;
try {
	theProblemID = new Long(theProblemIDStr);
} catch (Exception e) {
}

String theFromPage = request.getParameter(Constants.REQUEST_PARAMETER_FROM_PAGE);

WriteProblemAction theWriteProblemAction = ActionCreator.createWriteProblemAction();
UserAction theUserAction = ActionCreator.createUserAction();
TitlePostManageGroupDao theTitlePostManageGroupDao = DaoCreator.createTitlePostManageGroupDao();
ProblemDao theProblemDao = DaoCreator.createProblemDao();
RoleDao roleDao = DaoCreator.createRoleDao();

User theUser = (User) session.getAttribute(Constants.SESSION_USER);
JobPost thePost1 = theTitlePostManageGroupDao.getJobPostByID(theUser.getJobPost1ID());
JobPost thePost2 = theTitlePostManageGroupDao.getJobPostByID(theUser.getJobPost2ID());
JobPost thePost3 = theTitlePostManageGroupDao.getJobPostByID(theUser.getJobPost3ID());
Role theUserRole = theUserAction.getUserRole(request);

Problem theInnerProblem = theProblemDao.getProblemByID(theProblemID);

int intRole = theWriteProblemAction.calRole(thePost1, thePost2, thePost3, theUserRole);
%>

<%
if (roleDao.hasRight(Constants.AUTH_TYPE_ACCIDENT_FEEDBACK, theUserRole.getId(), Constants.PROCESS_METHOD_CLOSE)) {
%>
<input style="margin-left: 40px" type="radio" name="processRadio"
	id="processRadio1" onclick="chooseProcessMethod(1)"  checked="checked"/>
<%
	if ((intRole & (Constants.ROLE_TYPE_FUCHUZHANG | Constants.ROLE_TYPE_CHUZHANG | Constants.ROLE_TYPE_ZONGSHI | Constants.ROLE_TYPE_FUZONGJINGLI | Constants.ROLE_TYPE_ZONGJINGLI)) == 0) {
%>
<span>确认已整改</span>
<%
	} else {
%>
<span>确认同意</span>
<%
	}
%>
<%
}
%>
<%
if (roleDao.hasRight(Constants.AUTH_TYPE_ACCIDENT_FEEDBACK, theUserRole.getId(), Constants.PROCESS_METHOD_FEEDBACK)) {
	if((intRole & (Constants.ROLE_TYPE_KEZHANG | Constants.ROLE_TYPE_FUKEZHANG)) == 0) {
%>
<input style="margin-left: 40px" type="radio" name="processRadio"
	id="processRadio0" onclick="chooseProcessMethod(0)" />
<span>反馈</span>
<%
	}
}
%>
<%
if (roleDao.hasRight(Constants.AUTH_TYPE_ACCIDENT_FEEDBACK, theUserRole.getId(), Constants.PROCESS_METHOD_TRANSFER)) {
%>
<input style="margin-left: 20px" type="radio" name="processRadio"
	id="processRadio2" onclick="chooseProcessMethod(2)"/>
<span>阅知或通知他人处理</span>
<%
}
%>
<%
if (roleDao.hasRight(Constants.AUTH_TYPE_ACCIDENT_FEEDBACK, theUserRole.getId(), Constants.PROCESS_METHOD_SENDBACK)) {
%>
<input style="margin-left: 20px" type="radio" name="processRadio"
	id="processRadio4" onclick="chooseProcessMethod(4)" />
<span>退回补充</span>
<%
}
%>
<%
if (roleDao.hasRight(Constants.AUTH_TYPE_ACCIDENT_FEEDBACK, theUserRole.getId(), Constants.PROCESS_METHOD_OTHERDEPART)) {
%>
<input style="margin-left: 20px" type="radio" name="processRadio"
	id="processRadio5" onclick="chooseProcessMethod(5)" />
<%
if ((intRole & (Constants.ROLE_TYPE_CHUZHANG | Constants.ROLE_TYPE_ZONGSHI | Constants.ROLE_TYPE_FUZONGJINGLI | Constants.ROLE_TYPE_ZONGJINGLI)) == 0) {
%>
<a href="javascript:" onclick="openDialogPage('accident/feedback_escalate_userlist.jsp?id=<%=theProblemIDStr%>', 'escalateUserDialog', '选择上报领导')">相关单位协助解决</a>
<%
} else {
%>
<a href="javascript:" onclick="openDialogPage('depart_select/depart1_checkbox_section.jsp', 'escalateUserDialog', '选择相关单位协助解决')">相关单位协助解决</a>
<%
}
%>
<%
User escalateUser = (User) session.getAttribute(Constants.SESSION_ESCALATE_USER);
if (escalateUser != null) {
%>
<%=escalateUser.getName()%>
<%
}
%>
<%
List<Department1> escalateDepart1List = (List<Department1>) session.getAttribute(Constants.SESSION_PROBLEM_DEPARTMENT1);
if (escalateDepart1List != null && escalateDepart1List.size() > 0) {
	for (Department1 otherDepart : escalateDepart1List) {
%>
<%=otherDepart.getDepartmentName()%> 
<%
	}
}
%>
<%
}
%>
<%
if (roleDao.hasRight(Constants.AUTH_TYPE_ACCIDENT_FEEDBACK, theUserRole.getId(), Constants.PROCESS_METHOD_ESCALATE)) {
%>
<input style="margin-left: 20px" type="radio" name="processRadio"
	id="processRadio3" onclick="chooseProcessMethod(3)" 
<%
if((intRole & (Constants.ROLE_TYPE_SHENGCHANFUBUZHANG | Constants.ROLE_TYPE_ANQUANZONGJIAN | Constants.ROLE_TYPE_SHEBEIFUBUZHANG | Constants.ROLE_TYPE_BUZHANG)) > 0) {
%>
checked="checked"
<%
}
%>
/>
<%
if ((intRole & Constants.ROLE_TYPE_BUZHANG) == 0) {
%>
<a href="javascript:" onclick="openDialogPage('accident/feedback_escalate_userlist.jsp?id=<%=theProblemIDStr%>', 'escalateUserDialog', '选择上报领导')">上报职能处室</a>
<%
} else {
%>
<a href="javascript:" onclick="openDialogPage('department1_list.jsp?departType=<%=Constants.DEPARTMENT_TYPE_JIGUAN%>', 'escalateUserDialog', '选择上报职能处室')">上报职能处室</a>
<%
}
%>
<%
User escalateUser = (User) session.getAttribute(Constants.SESSION_ESCALATE_USER);
if (escalateUser != null) {
%>
<%=escalateUser.getName()%>
<%
}
%>
<%
Department1 escalateDepart1 = (Department1) session.getAttribute(Constants.SESSION_PROBLEM_DEPARTMENT1);
if (escalateDepart1 != null) {
%>
<%=escalateDepart1.getDepartmentName()%>
<%
}
%>
<%
}
%>

<script type="text/javascript">
function chooseMappingDepartment1(id) {
	$.dialog.get('escalateUserDialog').close();
	openWaitingDialog('waitingDialog');
	$.ajax({
		type:'post',
		url:'choose_department1_1_process.jsp',
		data:{
			id: id
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				if (obj.isSuccess == 'true') {
					loadPageSection('<%=request.getContextPath()%>/accident/feedback_process_method.jsp', 'feedbackProcessMethodDiv', {id: <%=theInnerProblem.getId()%>}, false,
					function() {
						var processRadio3 = document.getElementById('processRadio3');
						if (processRadio3 != null) {
							processRadio3.checked = true;
						}
						chooseProcessMethod(3);
						
						var processRadio5 = document.getElementById('processRadio5');
						if (processRadio5 != null) {
							processRadio5.checked = true;
						}
						chooseProcessMethod(5);
					});
				} else {
					$.dialog.alert(obj.error);
				}
				closeWaitingDialog('waitingDialog');
			}
		}
	});
}
</script>
<%
}
%>